package com.wlhse.controller;

import com.wlhse.entity.StudyCasePojo;
import com.wlhse.service.StudyCaseService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("StudyCaseController")
@RequestMapping("/api/v3")
//案例
public class StudyCaseController {

    @Resource
    private StudyCaseService studyCaseService;

    @RequestMapping(value = "/study_case/{id}", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
    public String updateStudyCase(@RequestBody(required = false) StudyCasePojo studyCasePojo, @PathVariable("id") int id) {
            studyCasePojo.setId(id);
            return studyCaseService.updateStudyCase(studyCasePojo);
    }

    @RequestMapping(value = "/study_case/{id}", method = RequestMethod.DELETE, produces = "application/json; charset=utf-8")
    public String deleteStudyCase(@PathVariable("id") int id) {
            return studyCaseService.deleteStudyCase(id);
    }

    @RequestMapping(value = "/study_case", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public String addStudyCase(@RequestBody(required = false) StudyCasePojo studyCasePojo) {
            return studyCaseService.addStudyCase(studyCasePojo);
    }

    @RequestMapping(value = "/study_case", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String selectAllStudyCase(@ModelAttribute StudyCasePojo studyCasePojo) {
            return studyCaseService.queryStudyCases(studyCasePojo);
    }

    @RequestMapping(value = "/study_case/{id}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String selectSingleProblemImportDto(@PathVariable("id") int id) {
            return studyCaseService.queryStudyCasesById(id);
    }
}
